<?php
/**
 * Created by PhpStorm.
 * User: ytlmi
 * Date: 2018/3/12
 * Time: 10:44
 */
namespace org\util\wordTool\example;

use org\util\wordTool\Table;
use org\util\forensicTool\LittleTools;

class ReportQz extends WriteReport
{

    protected function addSampleTable()
    {
        $table = $this->body->addTable(self::TABLE_STYLE);
        $roleGroup = $this->makeRoleGroup();
        $this->addRow($table,'head','first');
        if (in_array('M', $roleGroup[0])) {
            $this->addRow($table,'M');
            unset($roleGroup[0][array_keys($roleGroup[0],'M')]);
        }
        foreach ($roleGroup[1] as $role) {
            $this->addRow($table,$role);
        }
        foreach ($roleGroup[0] as $index=>$role) {
            $position = $index==count($roleGroup[0])-1 ? 'last' : 'mid';
            $this->addRow($table,$role,$position);
        }
    }

    protected function addRow(Table $table, $role, $position = 'mid')
    {
        $positionMap=['first'=>self::FIRST_ROW_STYLE,'mid'=>self::MID_ROW_STYLE,'last'=>self::LAST_ROW_STYLE];
        $width = [1100, 900, 900, 900, 2500, 1800];
        if ($role == 'head') {
            $content = ['被鉴定人', '性别', '称谓', '民族', '身份证件号码', '样本编号'];
        } else {
            $content = [
                $this->caseData['samples'][$role]['person_name'],
                LittleTools::formatSex($this->caseData['samples'][$role]['person_sex']),
                LittleTools::makeZhCalling($role),
                $this->caseData['samples'][$role]['person_race'],
                $this->caseData['samples'][$role]['person_id'],
                $this->caseData['samples'][$role]['sample_name']
            ];
        }
        $table->addSimpleRow($content, $width, self::TABLE_FONT, $positionMap[$position]);
    }

    protected function addDetectionTable(){}
}